package com.jason.data;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class LockDemo {
    public static void main(String[] args) {
        //Lock
        //多线程
        ThreadPoolExecutor executor = new ThreadPoolExecutor(2000, 5000, 2, TimeUnit.MINUTES,
                new ArrayBlockingQueue<Runnable>(5000));
        //模拟200人并发请求
        CountDownLatch latch = new CountDownLatch(1);
        //模拟100个用户
        for (int i = 0; i < 2000; i++) {

           /* AnalogUser analogUser = new AnalogUser(latch);
            executor.execute(analogUser);*/
            //HttpClient.doGet("http://localhost:8888/lock");
            RunnableDemo demo = new RunnableDemo(latch,i);
            executor.execute(demo);
        }
        //计数器減一  所有线程释放 并发访问。
        latch.countDown();

    }
}
